hysop.numerics.stencil.stencil module¶
Finite differences stencil inteface used in various numerical methods.
StencilGenerator
CenteredStencilGenerator
- class hysop.numerics.stencil.stencil.CenteredStencil(coeffs, origin, order, dx=dx, factor=1, error=None, **kwds)[source]¶
Bases:
Stencil
Centered stencil used for finite abitrary dimension differences.
Centered stencil used for finite abitrary dimension differences.
See also
CenteredStencilGenerator
Centered stencil generator.
- class hysop.numerics.stencil.stencil.Stencil(coeffs, origin, order, dx=dx, factor=1, error=None, delete_zeros=True)[source]¶
Bases:
object
Stencil used for finite abitrary dimension differences.
Stencil used for finite differences schemes (n-dimensional).
- Parameters:
coeffs (array_like) – Coefficients of the stencil.
origin (array_like) – Origin of the stencil from left-most point.
order (int) – Order of the stencil.
dx (sympy.Symbol or array_like of sympy.Symbol) – Spatial spacing symbols.
factor (dtype or sympy.Expr) – Common leading factors for all coefficients.
error (sympy.Expr) – Exact error if known.
- coeffs¶
Coefficients of the stencil.
- Type:
np.ndarray
- origin¶
Origin of the stencil from left-most point.
- Type:
np.ndarray
- shape¶
Shape of the stencil.
- Type:
np.ndarray
- L¶
Distance from origin to left-most point included in stencil support.
- Type:
np.ndarray
- R¶
Distance from origin to right-most point included in stencil support.
- Type:
np.ndarray
- dx¶
Spatial spacing symbols.
- Type:
sympy.Symbol or array_like of sympy.Symbol
- factor¶
Leading factor of all coefficients.
- Type:
dtype or sympy.Expr
- error¶
Exact error term if known or else None.
- Type:
sympy.Expr
- Raises:
ValueError – Raised if one component of origin is negative.
See also
CenteredStencil
Centered version of a stencil.
StencilGenerator
Generate Stencil objects.
- accuracy()[source]¶
Accuracy of the stencil with bigO notation.
- Returns:
accuracy – Accuracy in bigO notation.
- Return type:
sympy.Expr
- apply(a, out=None, axis=None, symbols=None, iview=Ellipsis)[source]¶
Apply this stencil the input array a. Boundaries are considered periodic.
- coo_stencil()[source]¶
Return a 2d stencil as a sparse coordinate matrix.
- Returns:
coo_stencil – Sparse Coordinate Matrix of the stencil.
- Return type:
- Raises:
RuntimeError – Raised if stencil is not 2d.
- hash(keep_only=16)[source]¶
Hash the stencil with its origin, order and coefficients. The hash algorithm used is sha1. By default only the 16 first chars are kept from the generated hash.
- Parameters:
keep_only (int) – Number of chars kept from the hashed hexedecimal string.
- Returns:
hash – Hexadecimal hash string of size
keep_only
.- Return type:
string
- is_centered(axe=None)[source]¶
Check if the stencil is centered (ie. stencil generate a centered finite differences scheme).
- Returns:
is_centered
- Return type:
- is_cross()[source]¶
Check if the stencil is a cross (zeros everywhere except on a n-dimensional axis aligned cross).
Examples: oo+oo o+oo oo+oo ++++ +++++ o+oo oo+oo o+oo
- Returns:
is_cross
- Return type:
- is_symbolic()[source]¶
Check if either the stencil leading factor or the stencil coefficients contains symbolic values.
- Returns:
is_symbolic
- Return type:
- items(include_factor=True)[source]¶
Return an (offset,coefficient) iterator iterating on all non zero coefficients. Offset is taken from origin.
- Returns:
it – Zipped offset and coefficient iterator.
- Return type:
itertools.iterator